<script>
	$(function() {			
		
		sagapo.section_class_change('board');
		
		// 게시물 신규 추가.
		$("section.section .btn_right a.writes").click(function() {
			
			var href = $(this).attr("href");
			if(href) {
				loadDialogForm(href, null, $(this).text(), 800, 710, null, 'create');
			} else {
				alert("링크가 존재하지 않습니다.");
			}
			
			return false;
		});
		
		$("#search_form").dialog({
			resizable	: false,
			modal		: true,
			width		: 400,
			minWidth	: 400,
			height		: 120,
			autoOpen	: false,
			title		: '검색'
		}).validate({
			submitHandler : function(form) {
				href = '{action}/bbs/{binfo->ba_id}/'+$("#search_form .kf").val()+'/'+$("#search_form .kw").val();
				sagapo.section_refresh(href);
			}	
		});
		
		$("section.board button.search").click(function() {
			$("#search_form").dialog('open');	
		});
		
		$("section.board .list_footer ul.paging a.page").click(function() {
			href = $(this).attr("href");
			sagapo.section_refresh(href);
			return false;
		});
		
		$("section.board .list_footer .paging_setting input[name='ls']").change(function() {
			//변경 로직
			href = '{search->url}ls='+$(this).val();
			sagapo.section_refresh(href);
			return false;
		});
	});
</script>
	
	
<div class="list_container">
	<ul class="list">
		{? list}
			{@ list}
		<li>
			<a href="{action}/view/{.value_->ba_id}/{.value_->b_seq}" class="article">
				<div class="info">
					<span class="writer {.value_->m_id}">{.value_->m_id}</span>
					<span class="hit">
						[HIT: <span class="hit_count_{.value_->b_seq}">{.value_->b_count}</span>]
					</span>
				</div>
				<h3 class="subject subject_{.value_->b_seq}">
					{? binfo->ba_category}
					<span class="category">[{.value_->bc_name}]</span>
					{/}
					{.value_->b_subject}
				</h3>
				<div class="info">
					<span class="date">
						{.value_->date}
					</span>
				</div>
			</a>
		</li>	
			{/}
		{:}
		<li class="no_list"> 등록된 게시글이 없습니다. </li>
		{/}		
	</ul>
	<div class="list_footer">
		<div class=btn_left>
			{? paging->totalPage > 1}
			<ul class="paging">
				{? paging->prevLink}
				<li>
					<a href="{search->url}{paging->prevLink}" class="icon_button page">
						<img src="{CFG->PATH->IMAGE}/icons/paging_prev.png" alt='prev' />
					</a>
				</li>
				{/}
				{@ paging->pageList}
				<li>
					<a href="{search->url}{.value_['link']}" class="button page{? .value_['current']} current{/}">{.value_['pageNum']}</a>
				</li>
				{/}
				{? paging->nextLink}
				<li>
					<a href="{search->url}{paging->nextLink}" class="icon_button page">
						<img src="{CFG->PATH->IMAGE}/icons/paging_next.png" alt='next' />
					</a>
				</li>
				{/}
			</ul>
			{/}
		</div>
		<div class="paging_setting">
			<input type="text" value="{search->ls}" name="ls" class="ls" maxlength="2" />개
		</div>
		<div class="btn_right">
			<button type="button" class="search">검색</button>
			<a href="{action}/add/{binfo->ba_id}" class="icon_button writes">게시글 추가</a>
		</div>
	</div>
	
	<div class="search_form">
		<form id="search_form" post="get" action="{action}/bbs/{binfo->ba_id}">
			<div class="elements">
				<select name="kf" class="kf">
					{@ search->kf}
					<option value="{.value_->value}">{.value_->text}</option>
					{/}
				</select>
				<input type="search" name="kw" placeholder="검색" class="kw required" />
			</div>
			<div class="buttons">
				<button type="submit">검색</button>
			</div>
		</form> 
	</div>
</div>		